#include "WorldMapFileReader.h"
WorldMapFileReader::WorldMapFileReader(){}
WorldMapFileReader::~WorldMapFileReader(){}
void WorldMapFileReader::FactoryWorldMap(){
	
	//find the file based on the int type
	const unsigned int total_digits = 8;
	char entity_number_string[total_digits];
	for(int i = 0; i < total_digits; i++)
		entity_number_string[i] = '\0';
	sprintf(entity_number_string, "%d", 0);

	char path[MAX_PATH_LENGTH];

	for(int i = 0; i < MAX_PATH_LENGTH; i++)
		path[i] = '\0';

	strcat(path, MAP_DIRECTORY);
	strcat(path, entity_number_string);
	strcat(path, MAP_EXTENSION);	

	//open the file
	OpenFile(path);
	
	//tokenize the file
	TokenizeFile();

	
	//populate the single map's grid
	int k;
	for(int i = 0; i < MAP_WIDTH; i++){
		for(int j = 0; j < MAP_HEIGHT; j++){
			//assign the fields to the entity
			k = i*j;
				if(GetToken(k) == "0"){
					
				}
				else if(GetToken(k) == "1"){
					Entity * e = entityFileReader.GetEntity(0);
					e->SetW(TILE_SIZE);
					e->SetH(TILE_SIZE);
					e->SetX(TILE_SIZE * i + TILE_SIZE/2);
					e->SetY(TILE_SIZE * j + TILE_SIZE/2);
					//WorldMap::tileMap[i][j] = e;
				}
			
		}
	}

	
	

	//factory them into the world map
	
}